﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="MusicZone.Spoke2"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MusicZone"
    xmlns:data="using:MusicZone.Data"
    xmlns:tiles="using:MusicZone.VariableTemplate"
    xmlns:common="using:MusicZone.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.TopAppBar>
        <AppBar Height="140" x:Name="TopBar" BorderBrush="{x:Null}">
            <common:TopAppBar x:Name="TopAppBar" Margin="0,10"/>
        </AppBar>
    </Page.TopAppBar>

    <Page.Resources>

        <!--
            Collection of grouped items displayed by this page, bound to a subset
            of the complete item list because items in groups cannot be virtualized
        -->
        <CollectionViewSource
            x:Name="groupedItemsViewSource"
            Source="{Binding Groups}"
            IsSourceGrouped="true"
            ItemsPath="TopItems"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:Spoke1DataSource, IsDesignTimeCreatable=True}}"/>

        <tiles:VariableTiles x:Name="MyTemplates"
                            ArtistItemTemplate="{StaticResource ArtistItemTemplate}">

        </tiles:VariableTiles>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
        <Style x:Key="BotAppBarRadioBtnStyle" TargetType="RadioButton">
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="RadioButton">
        				<Grid Background="Transparent" Width="25" Height="30">
        					<Grid.RowDefinitions>
        						<RowDefinition Height="2*"/>
        						<RowDefinition/>
        					</Grid.RowDefinitions>
        					<VisualStateManager.VisualStateGroups>
        						<VisualStateGroup x:Name="CommonStates">
        							<VisualStateGroup.Transitions>
        								<VisualTransition GeneratedDuration="0:0:0.15"/>
        							</VisualStateGroup.Transitions>
        							<VisualState x:Name="PointerOver"/>
        							<VisualState x:Name="Pressed"/>
        							<VisualState x:Name="Disabled"/>
        							<VisualState x:Name="Checked2"/>
        							<VisualState x:Name="CheckedPointerOver"/>
        							<VisualState x:Name="CheckedPressed"/>
        							<VisualState x:Name="CheckedDisabled"/>
        							<VisualState x:Name="Indeterminate2"/>
        							<VisualState x:Name="IndeterminatePointerOver"/>
        							<VisualState x:Name="IndeterminatePressed"/>
        							<VisualState x:Name="IndeterminateDisabled"/>
        						</VisualStateGroup>
        						<VisualStateGroup x:Name="CheckStates">
        							<VisualState x:Name="Unchecked"/>
        							<VisualState x:Name="Indeterminate1"/>
        							<VisualState x:Name="Checked">
        								<Storyboard>
        									<DoubleAnimation Duration="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectangle" d:IsOptimized="True" To="1"/>
        								</Storyboard>
        							</VisualState>
        							<VisualState x:Name="Indeterminate"/>
        						</VisualStateGroup>
        						<VisualStateGroup x:Name="FocusStates">
        							<VisualState x:Name="Unfocused"/>
        							<VisualState x:Name="PointerFocused"/>
        						</VisualStateGroup>
        					</VisualStateManager.VisualStateGroups>
        					<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{TemplateBinding Content}" VerticalAlignment="Bottom" FontSize="{TemplateBinding FontSize}"/>
        					<Rectangle x:Name="rectangle" Fill="#FFEAFF00" Height="2" VerticalAlignment="Top" Grid.Row="1" Opacity="0"/>
        				</Grid>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
    </Page.Resources>
	<common:LayoutAwarePage.BottomAppBar>
		<AppBar x:Name="appBar" Height="110" BorderBrush="{x:Null}" Background="Black">
			<VariableSizedWrapGrid Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
				<RadioButton Content="A" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" GroupName="SelectOne" FontSize="17.333" Margin="10,0" IsChecked="True"/>
				<RadioButton Content="B" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="C" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="D" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="E" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="F" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="G" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="H" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="I" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="J" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="K" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="L" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="M" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="N" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="O" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" GroupName="SelectOne" FontSize="17.333" Margin="10,0" IsChecked="False"/>
				<RadioButton Content="P" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="Q" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="R" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="S" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="T" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="U" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="V" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="W" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="X" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="Y" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
				<RadioButton Content="Z" HorizontalAlignment="Left" Style="{StaticResource BotAppBarRadioBtnStyle}" VerticalAlignment="Center" IsChecked="False" GroupName="SelectOne" FontSize="17.333" Margin="10,0"/>
			</VariableSizedWrapGrid>
		</AppBar>
	</common:LayoutAwarePage.BottomAppBar>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Horizontal scrolling grid used in most view states -->
        <ScrollViewer x:Name="MainScroll" Grid.RowSpan="2" Style="{StaticResource HorizontalScrollViewerStyle}">

            <tiles:VariableTileControl
            x:Name="itemGridView"
            AutomationProperties.AutomationId="itemGridView"
            AutomationProperties.Name="Grouped Items"           
            Padding="116,137,40,46"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplateSelector="{StaticResource MyTemplates}"
            SelectionMode="None"
            IsSwipeEnabled="false">

                <tiles:VariableTileControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Horizontal" Margin="0,0,80,0"/>
                    </ItemsPanelTemplate>
                </tiles:VariableTileControl.ItemsPanel>
                <tiles:VariableTileControl.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <Grid Margin="1,0,0,6">
                                    <Button
                                    AutomationProperties.Name="Group Title"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                            <!--<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>-->
                                        </StackPanel>
                                    </Button>
                                </Grid>
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>
                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid ItemHeight="10" ItemWidth="10" Orientation="Vertical" Margin="0,0,80,0"/>
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </tiles:VariableTileControl.GroupStyle>
            </tiles:VariableTileControl>
        </ScrollViewer>

        <!-- Vertical scrolling list only used when snapped -->
        <ListView
            x:Name="itemListView"
            AutomationProperties.AutomationId="ItemListView"
            AutomationProperties.Name="Grouped Items"
            Grid.Row="1"
            Visibility="Collapsed"
            Margin="0,-10,0,0"
            Padding="10,0,0,60"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplate="{StaticResource Standard80ItemTemplate}"
            SelectionMode="None"
            IsSwipeEnabled="false">

            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="7,7,0,0">
                                <Button
                                    AutomationProperties.Name="Group Title"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                        <!--<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>-->
                                    </StackPanel>
                                </Button>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Text="Your Page title goes here" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/>
            <Image x:Name="AppLogo" Source="/Assets/AppLogo.png" Grid.Column="2" HorizontalAlignment="Right" Margin="-12,0,10,0" Height="90"/>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="96,137,10,56"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="AppLogo" Storyboard.TargetProperty="HorizontalAlignment">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Left"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>                       

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="AppLogo" Storyboard.TargetProperty="HorizontalAlignment">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Left"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TopBar" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="appBar">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
